package javase.thread;

/**
 * @author hck
 */
public class TestMemoryVolita {
    private static boolean flag = false;

    private static void reset() {
        flag = true;
    }

    public static void main(String[] args) throws InterruptedException {
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (!flag) {
//                try {
//                    Thread.sleep(100);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
                }
                System.out.println("read thread end");
            }
        }).start();

        Thread.sleep(1000);

        new Thread(new Runnable() {

            @Override
            public void run() {
                System.out.println("reset thread start");
                reset();
                System.out.println("reset thread end");
            }
        }).start();
    }
}
